
using System.Collections.Generic;
using UnityEditor; 

namespace XFGameFramework.PanelExtension
{



    [CustomEditor(typeof(SelectableEvent))]
    public class SelectableEventInspector : Editor
    {
        private List<SerializedProperty> properties = null;
        private SerializedProperty mScript = null;


        private SerializedProperty EnableHighlighted = null;
        private SerializedProperty EnablePressed = null;
        private SerializedProperty EnableSelected = null;


        private void OnEnable()
        {
            mScript = serializedObject.FindProperty("m_Script");
            properties = serializedObject.GetAllSerializedProperty();

            EnableHighlighted = serializedObject.FindProperty("enableHighlighted");
            EnablePressed = serializedObject.FindProperty("enablePressed");
            EnableSelected = serializedObject.FindProperty("enableSelected");
        }

        public override void OnInspectorGUI()
        {

            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.PropertyField(mScript);
            EditorGUI.EndDisabledGroup();

            serializedObject.Update();

            foreach (var property in properties)
            {
                bool disable = false;

                if (property.name == "onHighlighted" && !EnableHighlighted.boolValue)
                    disable = true;

                if (property.name == "onPressed" && !EnablePressed.boolValue)
                    disable = true;

                if (property.name == "onSelected" && !EnableSelected.boolValue)
                    disable = true;

                EditorGUI.BeginDisabledGroup(disable);
                EditorGUILayout.PropertyField(property);
                EditorGUI.EndDisabledGroup();
            }

            serializedObject.ApplyModifiedProperties();

        }


    }
}